import 'dart:io';

import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tetap_ad_batch/app.dart';
import 'package:tetap_ad_batch/common/platform/windows.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'config.dart';

void main() async {
  Config.appFlavor = Flavor.DEVELOPMENT;
  WidgetsFlutterBinding.ensureInitialized();
  await WindowBinding.initialized();
  final savedThemeMode = await AdaptiveTheme.getThemeMode();
  await WindowBinding.initialized();

  runApp(ProviderScope(child: App(savedThemeMode: savedThemeMode)));

  /// 自定义报错页面
  ErrorWidget.builder = (FlutterErrorDetails flutterErrorDetails) {
    debugPrint(flutterErrorDetails.toString());
    return const Center(child: Text("App错误，快去反馈给作者!"));
  };

  /// Android状态栏透明
  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
        const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }

  GestureBinding.instance.resamplingEnabled = true;
  
}
